/**
 * @author		Ben Layet
 * @version 	0.1
 * @date		31 Oct 2008
 * @copyright 	� Canon Europa N. V. 2004
 */
package org.ignoramus.application.view;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

import org.ignoramus.application.model.Cards;
import org.ignoramus.application.model.ReviewCard;

/**
 * 
 */
public abstract class AbstractCardsView implements CardsView
{

	private final Map<ReviewCard, CardView> cardViews	= new LinkedHashMap<ReviewCard, CardView>();

	protected void init(Cards cards)
	{
		for (Iterator<String> iterator = cards.keySet().iterator(); iterator.hasNext();)
		{
			String	cardId = iterator.next();
			ReviewCard	card = cards.get(cardId);
			CardView cardView = createCardView(cardId, cards );
			addCardView(cardView);
			cardViews.put(card, cardView);
		}
	}
	
	/**
	 * @param card
	 * @return
	 */
	@Override
	public CardView getCardView(ReviewCard card)
	{
		return cardViews.get(card);
	}

	abstract protected CardView createCardView(String cardId, Cards cards);
	abstract protected void addCardView(CardView cardView);
}
